package com.hui.auth.dto;

import com.alibaba.fastjson.JSONObject;

/**
 * 通用Json数据传输
 * Created by LiaoYunHui on 2016/11/16.
 */
public class JsonResult<T> {
    private T data;
    private String msg = "";
    private Integer code = 200;

    public JsonResult() {

    }

    public JsonResult(String msg) {
        this.msg = msg;
        this.data = null;
    }

    public JsonResult(T data) {
        this.msg = "";
        this.data = data;
    }

    public JsonResult(boolean success, String msg, T data) {
        this.msg = msg;
        this.data = data;
    }

    public T getData() {
        return data;
    }

    public JsonResult<T> setData(T data) {
        this.data = data;
        return this;
    }

    public String getMsg() {
        return msg;
    }

    public JsonResult<T> setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public Integer getCode() {
        return code;
    }

    public JsonResult<T> setCode(Integer code) {
        this.code = code;
        return this;
    }

    @Override
    public String toString() {
        return JSONObject.toJSONString(this);
    }
}
